package com.byinsight.web.actions.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.byinsight.web.actions.ErrorCode;
import com.byinsight.web.actions.WebException;

public class DateUtil {

	private static SimpleDateFormat sdf = new SimpleDateFormat("M/d/yyyy");
	
	public static String dateToString(Date date) {
		return sdf.format(date);
	}
	
	public static Date StringToDate(String dateStr) {
		try {
			Date ret = sdf.parse(dateStr);
			return ret;
		} catch (Exception e) {
			throw new WebException(ErrorCode.DATE_PARSE_ERROR);
		}
	}
}
